// 引入 Emitter 类
import Emitter from '../../src/utils/emitter.js';

const emitter = new Emitter();

//////////////////测试触发多次事件/////////////////////////

function handleEvent(data) {
    console.log('receive an event, data:', data);
}

emitter.on('test_event', handleEvent);

emitter.emit('test_event', "hello world!");
emitter.emit('test_event', "您好！");


//////////////////测试触发单次事件/////////////////////////

function handleOnceEvent(data) {
    console.log('receive once event, data:', data);
}

emitter.once('test_once_event', handleOnceEvent, null);

emitter.emit('test_once_event', "hello world!");
emitter.emit('test_once_event', "您好！");//不触发
